const express=require("express")
const cookieParse=require("cookie-parser")
const session=require("express-session")
const app=express()
app.use(cookieParse())
app.use(session({
    secret:"hubwizApp", 
    cookie:{maxAge:60*1000*60*24},
    resave:true,
    // 即使session没被修改，也保存session值，默认为true
    saveUninitialized:false
    // 无论有没有session cookie，每次请求都设置个session cookie,默认为connect.sid  
}))
app.get("/visit",function(req,res){
if(req.session.count==undefined){
    req.session.count=1
}else{
    req.session.count++
}
res.send({
    count:"本页面访问l"+req.session.count
})
})
app.listen(3000)